<template>
  <page-body>
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center myTracks_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub myTracks_fd0_0'>
          <view class='flex flex-wrap align-center myTracks_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  myTracks_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='myTracks_fd0_0_c1_c0'> {{type==1 ? '我的点赞 ' :
            type==2 ? '我的足迹 ' :
            type==3 ? '我的收藏 ' : ''
            }}</text>
          </view>
          <view class='flex flex-wrap align-center justify-end myTracks_fd0_0_c0'>
            <!-- <image class='myTracks_fd0_0_c2_c0' mode="aspectFit" :src='STATIC_URL+"163.png"'></image> -->
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view v-for="(item,index) in dataList" :key="index">
        <view class="flex benben-flex-layout flex-wrap align-center myTracks_flex_1">
          <text class='myTracks_fd1_0'>{{item.datetime}}</text>
        </view>
        <!---flex布局flex布局开始-->
        <view class="flex benben-flex-layout flex-wrap align-center myTracks_flex_2">
          <view class='flex flex-wrap align-center myTracks_fd2_0' v-for="(itemC,indexC) in item.goods" :key="indexC"
            @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/homePage/detail/detail?aid=${itemC.goods_id}`">
            <view class="myTracks_fd2_0_c0 position-relative">
              <image class='myTracks_fd2_0_c0' mode="aspectFill" :src='itemC.goods_thumb[0]'></image>
              <view @click.stop="chooseCheck(itemC)">
                <image v-if="itemC.cheked" class='check-box' mode="aspectFit" :src='STATIC_URL+"15.png"'></image>
                <image v-else class='check-box' mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
              </view>
            </view>

            <view class='flex flex-direction flex-wrap align-stretch myTracks_fd2_0_c1'>
              <text class='myTracks_fd2_0_c1_c0'>{{itemC.goods_name}}</text>
              <view class='flex flex-wrap align-center justify-between myTracks_fd2_0_c1_c1'>
                <text class='myTracks_fd2_0_c1_c1_c0'>{{itemC.exhibition==1 ? '可售' : '分享'}}</text>
                <view class='flex flex-wrap align-center'>
                  <text class='myTracks_fd2_0_c1_c1_c1_c0'>{{itemC.viewcount}} 浏览</text>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
      <fu-empty-ui v-if="dataList.length==0"></fu-empty-ui>

      <!---flex布局flex布局结束-->


    </view>
    <view style="height:150rpx"></view>
    <view v-if="dataList.length"
      class="flex flex-wrap align-center justify-between benben-position-layout position-fixed flex myfavorites_flex_6"
      :style="{height:(100+bottomSafeAreaRpx)+'rpx',paddingBottom:bottomSafeAreaRpx+'rpx', }">
      <view class='flex flex-wrap align-center myfavorites_fd6_0' @click.stop="checkAll">
        <image class='myfavorites_fd6_0_c0' v-if="!isCheckAll" mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
        <image class='myfavorites_fd6_0_c1' v-else mode="aspectFit" :src='STATIC_URL+"15.png"'></image>
        <text class='myfavorites_fd6_0_c2'>全选</text>
      </view>
      <button class='myfavorites_fd6_1' @click.stop="delPost">删除</button>

    </view>
  </page-body>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "dataList": [],
        type: 1,
        checklist: [],
        isCheckAll: false,
        total: 0
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      this.type = options.type
      this.getxj4145c1253b3eFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      delPost() {
        this.checklist = []

        for (var i = 0; i < this.dataList.length; i++) {
          let obj = this.dataList[i].goods.filter(itemC => {
            return itemC.cheked
          })
          console.log('this.obj', obj)
          // this.checklist = obj
          for (var j = 0; j < obj.length; j++) {
            this.checklist.push(obj[j])
          }
        }
        let ids = ''
        if (this.checklist.length == 0) {
          this.$message.info('请选择操作数据')
          return
        }
        if (this.checklist.length) {
          if (this.type == 1) {
            ids = this.checklist.map(item => {
              return item.aid
            }).join(',')
          }
          if (this.type == 2) {
            ids = this.checklist.map(item => {
              return item.aid
            }).join(',')
          }
          if (this.type == 3) {
            ids = this.checklist.map(item => {
              return item.aid
            }).join(',')
          }
        }
        let urls = ''
        if (this.type == 1) {
          urls = global.apiUrls.post66a318272312d
        } else if (this.type == 2) {
          urls = global.apiUrls.post64145e74b3a92
        } else {
          urls = global.apiUrls.post66a319ed0507b
        }
        this.$api.post(urls, {
          aid: ids
        }).then(res => {
          this.checklist = []
          this.$message.info(res.data.msg)
          if (res.data.code == 1) {
            this.isCheckAll = false
            this.getxj4145c1253b3eFunc()
          }
        })
      },
      chooseCheck(item) {
        item.cheked = !item.cheked
        for (var i = 0; i < this.dataList.length; i++) {
          this.checklist = this.dataList[i].goods.filter(itemC => itemC.cheked)
        }
        if (this.checklist.length == this.total) {
          this.isCheckAll = true
        } else {
          this.isCheckAll = false
        }
      },
      checkAll() {

        this.isCheckAll = !this.isCheckAll
        for (var i = 0; i < this.dataList.length; i++) {
          // this.dataList[i].cheked = this.isCheckAll
          this.dataList[i].goods.map(item => {
            item.cheked = this.isCheckAll
          })
        }
        console.log('this.dataList', this.dataList)
      },
      //用户管理-足迹列表
      async getxj4145c1253b3eFunc() {
        //请求方法
        //数据验证
        let urls = ''
        if (this.type == 1) {
          urls = global.apiUrls.post669b27f416732
        } else if (this.type == 2) {
          urls = global.apiUrls.post64145c1253b3e
        } else {
          urls = global.apiUrls.post636cabd662b22
        }

        let datadataList = await this.$api.get(urls, {});

        if (datadataList.data.code != 1) {
          this.$message.info(datadataList.data.msg);
          return
        }
        let infodataList = datadataList.data;
        this.dataList = infodataList.data
        for (var i = 0; i < this.dataList.length; i++) {
          this.total = this.dataList[i].goods.length + this.total
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .myfavorites_fd6_1 {
    background: linear-gradient(180deg, #176BE8 0%, #5A5CFC 100%);
    ;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    width: 230rpx;
    font-size: 24rpx;
    color: #fff;
    height: 100rpx;
    line-height: 100rpx;
  }

  .myfavorites_flex_6 {
    background: rgba(255, 255, 255, 1);
    width: 750rpx;
    height: 100rpx;
    position: fixed;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    left: 0rpx;
    background-size: 100% auto;
  }

  .myfavorites_fd6_0_c2 {
    margin: 0rpx 0rpx 0rpx 24rpx;
  }

  .myfavorites_fd6_0_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .myfavorites_fd6_0_c0 {
    width: 32rpx;
    height: 32rpx;
  }

  .myfavorites_fd6_0 {
    margin: 0rpx 0rpx 0rpx 32rpx;
  }

  .check-box {
    width: 32rpx;
    height: 32rpx;
    position: absolute;
    top: 16rpx;
    left: 16rpx;
    z-index: 2
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .myTracks_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .myTracks_fd0_0_c2_c0 {
    width: 40rpx;
    height: 40rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .myTracks_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .myTracks_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .myTracks_fd0_0_c0 {
    width: 120rpx;
  }

  .myTracks_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .myTracks_flex_1 {
    width: 720rpx;
    margin: 24rpx auto 24rpx auto;
  }

  .myTracks_fd1_0 {
    color: rgba(102, 102, 102, 1);
  }

  .myTracks_flex_2 {
    margin: 0rpx auto 0rpx auto;
    width: 702rpx;
    padding-bottom: 40rpx;
  }

  .myTracks_fd2_0_c1_c1_c1_c0 {
    font-size: 24rpx;
    color: rgba(153, 153, 153, 1);
  }

  .myTracks_fd2_0_c1_c1_c0 {
    font-weight: 600;
    color: rgba(255, 72, 59, 1);
  }

  .myTracks_fd2_0_c1_c1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .myTracks_fd2_0_c1_c0 {
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    height: 80rpx;
  }

  .myTracks_fd2_0_c1 {
    margin: 24rpx auto 20rpx auto;
    width: 320rpx;
  }

  .myTracks_fd2_0_c0 {
    width: 346rpx;
    height: 346rpx;
    border-radius: 16rpx 16rpx 0rpx 0rpx;
  }

  .myTracks_fd2_0 {
    background: #FFFFFF;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    width: 346rpx;
    margin: 16rpx 0 0rpx 0rpx;
  }

  .myTracks_fd2_0:nth-child(2n) {
    margin: 16rpx 0 0rpx 10rpx;
  }
</style>
